package com.zhdl.modules.demo.aoptest;

import com.zhdl.common.util.WebResult;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class PermissionAspect {

    @Around("@annotation(zhdlPermission)")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint, ZHDLPermissions zhdlPermission) throws Throwable {
        log.info("当前方法需要权限" + zhdlPermission.value());
        if (PermissionConsts.D.equals(zhdlPermission.value())){
            return WebResult.failResult("当前未有权限!");
        }
        return proceedingJoinPoint.proceed();
    }
}
